package written_test;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author zhx
 * @since 2020-09-02
 */
public class CTS {

    public static int solution() {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] dp = new int[n];
        dp[0] = 1;
        dp[1] = 2;
        for (int i = 2; i <= n - 1; i++) {
            dp[i] = dp[i - 1] + dp[i - 2];
        }
        System.out.println(" ");
        System.exit(0);
        return dp[n - 1];
    }

    public static int house(int[] person) {
        // write code here
        int[] houses = new int[person.length];
        if (person.length == 1) {
            return 1;
        }
        houses[0] = person[0] > person[1] ? 2 : 1;
        for (int i = 1; i < person.length - 1; i++) {
            if (person[i] > person[i - 1]) {
                houses[i] = houses[i - 1] +1;
            } else {
                houses[i] = 1;
            }
        }
        if (person[person.length - 1] > person[person.length - 2]) {
            houses[person.length - 1] = houses[person.length - 2] + 1;
        } else {
            houses[person.length - 1] = 1;
        }
        return Arrays.stream(houses).sum();
    }

    public static void main(String[] args) {
        System.out.println(CTS.house(new int[]{3, 2, 4}));
    }

}
